package org.telegram.bot.mq.producer;

import com.ruoyi.common.mq.RedisMQTemplate;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import org.telegram.bot.mq.message.GroupCacheRefreshMessage;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;

/**
 * @Author: wyx
 * @Date: 2024/12/2 0:56
 */
@Slf4j
@Component
public class GroupCacheRefreshProducer  {
    
    @Resource
    private RedisMQTemplate redisMQTemplate;
    
    public void sendMessage() {
        sendMessage(new ArrayList<>());
    }
    public int sendMessage(Long charId) {
        sendMessage(Collections.singletonList(charId));
        return 1;
    }
    /**
     * 发送 {@link GroupCacheRefreshMessage} 消息
     */
    public void sendMessage(Long[] ids) {
        sendMessage(Arrays.asList(ids));
    }
    
    public void sendMessage(List<Long> ids) {
        GroupCacheRefreshMessage message = new GroupCacheRefreshMessage();
        message.setChatIds(ids);
        redisMQTemplate.send(message);
    }
}
